﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xiaov.SmartWeb.Model.Statistical.Tags;
using System.Reflection;
using Xiaov.SmartWeb.Model.Statistical;
using Xiaov.SmartWeb.Model;
using Xiaov.SmartWeb.Model.Statistical.Select;
using Maticsoft.DBUtility;
using System.Data.OracleClient;
using System.Data;
using Xiaov.SmartWeb.Application.Models;

namespace Xiaov.SmartWeb.Application.SZBBTree
{
  public partial class report : BasePage
  {
    public string sum = "false";
    public string bbbm;
    public XMLVERSION modelXml = null;
    protected void Page_Load(object sender, EventArgs e)
    {
      if (Request.QueryString["tn"] != null)
      { bbbm = Request.QueryString["tn"].ToString(); }
      bbbm = "CL0060";
      if (!Page.IsPostBack)
      {
        //PM_Filter();
        //sum = Permissions[7].Allow ? "false" : "true";
        BindDW();
        BindNF();
        BindYF();
      }
      modelXml = new XMLVERSION(ddlNF.SelectedValue, ddlYF.SelectedValue, ddlDW.SelectedValue, bbbm);
    }

    protected void BindDW()
    {
      string sql = "select y.dwmc,t.dwbm from bbdytbdw t,dwbmb y where t.dwbm=y.dwbm and t.bbbm='" + bbbm.ToUpper() + "'";
      DataSet ds = DbHelperOra.Query(sql);
      ddlDW.DataValueField = "DWBM";
      ddlDW.DataTextField = "DWMC";
      ddlDW.DataSource = ds;
      ddlDW.DataBind();
      if (Request.Cookies["UserSelectInfo"] != null)
        ddlDW.SelectedValue = Request.Cookies["UserSelectInfo"]["DW"].ToString();
    }

    protected void BindNF()
    {
      int start = 2013;
      int end = DateTime.Now.Year + 1;
      for (int i = start; i < end; i++)
      {
        ListItem li = new ListItem();
        li.Value = i.ToString();
        li.Text = i.ToString();
        ddlNF.Items.Add(li);
      }
      if (Request.Cookies["UserSelectInfo"] != null)
        ddlNF.SelectedValue = Request.Cookies["UserSelectInfo"]["NF"].ToString();
      else
        ddlNF.SelectedValue = DateTime.Now.Year.ToString();
    }

    protected void BindYF()
    {
      int start = 1;
      int end = 12;
      for (int i = start; i < end; i++)
      {
        ListItem li = new ListItem();
        li.Value = i.ToString();
        li.Text = i.ToString();
        ddlYF.Items.Add(li);
      }
      if (Request.Cookies["UserSelectInfo"] != null)
        ddlYF.SelectedValue = Request.Cookies["UserSelectInfo"]["YF"].ToString();
      else
        ddlYF.SelectedValue = DateTime.Now.Month.ToString();
    }
  }
}